package ${customFilePackageName};

import top.jiangqiang.qianyi.business.model.request.${entity}ListRequest;
import top.jiangqiang.qianyi.business.model.request.${entity}PageRequest;
import top.jiangqiang.qianyi.business.model.request.${entity}SaveRequest;
import top.jiangqiang.qianyi.business.model.request.${entity}UpdateRequest;
import top.jiangqiang.qianyi.business.model.response.${entity}DetailResponse;
import top.jiangqiang.qianyi.business.model.response.${entity}ListResponse;
import top.jiangqiang.qianyi.business.model.response.${entity}PageResponse;
import top.jiangqiang.qianyi.common.base.response.PageResult;
import top.jiangqiang.qianyi.common.base.response.Result;
import top.jiangqiang.qianyi.data.model.entity.${entity};
import top.jiangqiang.qianyi.data.service.${entity}DbService;
import top.jiangqiang.qianyi.business.service.${entity}Service;
import top.jiangqiang.qianyi.common.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
public class ${customClassName} extends ${customSuperEntityClass}<${table.serviceName}, ${entity}> implements ${customInterface} {

    @Override
    public Result<PageResult<${entity}PageResponse>> page(${entity}PageRequest request) {
        PageResult<${entity}PageResponse> page=request.toPage();
        return Result.ok(getBaseDbService().lambdaJoinWrapper().page(page,${entity}PageResponse.class));
    }

    @Override
    public Result<List<${entity}ListResponse>> list(${entity}ListRequest request) {
        return Result.ok(getBaseDbService().lambdaJoinWrapper().list(${entity}ListResponse.class));
    }

    @Override
    public Result<Void> add(${entity}SaveRequest request) {
        ${entity} ${entity?uncap_first}=typeConverter.convert(request, ${entity}.class);
        save(${entity?uncap_first});
        return Result.ok();
    }

    @Override
    public Result<Void> update(${entity}UpdateRequest request) {
        ${entity} ${entity?uncap_first}=typeConverter.convert(request, ${entity}.class);
        updateById(${entity?uncap_first});
        return Result.ok();
    }

    @Override
    public Result<${entity}DetailResponse> detail(Long id) {
        return Result.ok(getById(id,${entity}DetailResponse.class));
    }

    @Override
    public Result<Void> delete(Long id) {
        removeById(id);
        return Result.ok();
    }

}